import { Modal } from 'antd'
import { useCallback, useRef } from 'react'
import SetRootIdAddForm from './SetRootIdAddForm'

const SetRootIdAdd = (props) => {
  const refIns = useRef()
  const { isModalOpen, handleAdminGroup } = props
  const handleOk = useCallback(async () => {
    try {
      await refIns.current.submit()
      handleAdminGroup(false, true)
    } catch (error) {
      console.log(error)
    }
  })
  const handleCancel = useCallback(() => {
    handleAdminGroup(false)
  })
  return (
    <Modal
      title="Basic Modal"
      visible={isModalOpen}
      onOk={handleOk}
      onCancel={handleCancel}
      style={{
        maxHeight: '500px',
        overflow: 'auto',
      }}
    >
      <SetRootIdAddForm ref={refIns} />
    </Modal>
  )
}

export default SetRootIdAdd
